//
//  HomeNewSiteCell3.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/7/3.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "HomeNewSiteCell3.h"
#import "UIImageView+WebCache.h"


#import "WHScrollAndPageView.h"
#import "API.h"

#define num _advertiseArr.count
@interface HomeNewSiteCell3()<WHcrollViewViewDelegate>
{
    WHScrollAndPageView *_whView;
}
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
@property (weak, nonatomic) IBOutlet UIPageControl *page;

@property (nonatomic,strong)NSTimer *timer;
@property (nonatomic,assign)NSInteger second;
@end
@implementation HomeNewSiteCell3

+(CGFloat)getHeightWithTableView:(UITableView *)tableview withArr:(NSArray *)arr
{
    
    if(arr.count > 0){
      return 100;
    }else{
        return 0;
    }
    
    
}

+(instancetype) cellWithTableView:(UITableView *)tableview;
{
    static NSString *ID = @"HomeNewSiteCell3";
    HomeNewSiteCell3 *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HomeNewSiteCell3" owner:nil options:nil]lastObject];
        
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
    
    return cell;
}


-(void)setAdvertiseArr:(NSArray *)advertiseArr
{
    _advertiseArr = advertiseArr;
    _whView = [[WHScrollAndPageView alloc] initWithFrame:self.contentView.bounds];
    
      NSMutableArray *tempAry = [NSMutableArray array];
    if (advertiseArr.count > 0) {
        
        for (int i=0; i<num; i++) {
            
            UIImageView *imageView = [[UIImageView alloc] init];
            [imageView sd_setImageWithURL:[NSURL URLWithString:[API imgUrlMake:[self.advertiseArr objectAtIndex:i]]] placeholderImage:nil];
         
            
            [tempAry addObject:imageView];
        }
        //把imageView数组存到whView里
        [_whView setImageViewAry:tempAry];
        
        //把图片展示的view加到当前页面
        [self.contentView addSubview:_whView];
        
        //开启自动翻页
        [_whView shouldAutoShow:YES];
        
        //遵守协议
        _whView.delegate = self;
        _advertiseArr = advertiseArr;
    }
   
}





@end
